/**
 * Created by lipo on 2017/8/11.
 */

import React, {Component} from 'react';

import {
    StyleSheet,
    View,
    Text,
    Button,
} from 'react-native';

import NetUitl from './NetUitl';

export default class MainScreen extends Component {

    constructor(props) {
        super(props)
        this.state = {
            dataJSON: {},
            titleText: "",
            textName: "",
            textHttp: '',
            text: "",
            url: ''
        }
    }

    getData() {
        var _this = this
        NetUitl.get('https://api.jumi.xingnext.com/startup', '', function (responseData) {
            //下面是请求下来的数据
            // console.log(set)
            // alert(set)
            // alert(responseData['data']['version_name']);
            _this.toData(responseData)

        })

    }

    toData(responseData) {
        // alert(responseData['data']['version_name']);
        this.setState({
            // textHttp : JSON.stringify(responseData),
            dataJSON: responseData
        })

        // alert(JSON.stringify(this.state.dataJSON))
    }

    render() {
        return (
            <View style={styles.container}>
                <Button style={styles.buttonCss} onPress={this.getData.bind(this)} title="点击获取请求"/>
                <Text style={styles.text_container}>
                    {

                    }
                </Text>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#F5FCFF',
    },
    buttonCss: {
        width: this.width,
        height: 100,
        justifyContent: 'center',
        alignItems: 'center',
    },
    welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
    },
    instructions: {
        fontSize: 20,
        textAlign: 'center',
        color: '#333333',
        height: 60,
        marginBottom: 5,
        justifyContent: 'center',
        alignItems: 'center',
    },
    text_container: {
        fontSize: 20,
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
    },
});
